package com.csweimei.rentmanagementtreasure.pop;

import android.content.Context;
import android.content.Intent;
import android.widget.ImageView;
import android.widget.LinearLayout;

import androidx.annotation.NonNull;

import com.csweimei.rentmanagementtreasure.R;
import com.csweimei.rentmanagementtreasure.base.AppConfig;
import com.csweimei.rentmanagementtreasure.enterprise.act.VipActivity;
import com.csweimei.rentmanagementtreasure.tenant.ui.act.VipPersonActivity;
import com.csweimei.rentmanagementtreasure.tenant.ui.act.customer.AddCustomerActivity;
import com.csweimei.rentmanagementtreasure.tenant.ui.act.house.AddHouseHzActivity;
import com.csweimei.rentmanagementtreasure.tenant.ui.act.house.AddHouseZzActivity;
import com.lxj.xpopup.core.BottomPopupView;

import me.goldze.mvvmhabit.utils.ToastUtils;

public class PopHomeAdd extends BottomPopupView {
    private Context mContext;


    private LinearLayout addZz,addHz,addKh;


    public PopHomeAdd(@NonNull Context context) {
        super(context);
        this.mContext = context;
    }

    int mHouseNum;
    public void setHouseNum(int houseNum){
        mHouseNum = houseNum;
    }

    int mZyNum;
    public void setZyNum(int ZyNum){
        mZyNum = ZyNum;
    }


    int mCusNum;
    public void setCusNum(int houseNum){
        mCusNum = houseNum;
    }


    @Override
    protected int getImplLayoutId() {
        return R.layout.pop_h_add;
    }

    @Override
    protected void onCreate() {
        addZz = findViewById(R.id.add_zz);
        addHz = findViewById(R.id.add_hz);
        addKh = findViewById(R.id.add_kh);
        ImageView cancel = findViewById(R.id.pop_close);
        cancel.setOnClickListener(view -> dismiss());


        addZz.setOnClickListener(v -> {
            if (AppConfig.isPersonVip() || mHouseNum <= AppConfig.FREE_NUM){
                mContext.startActivity(new Intent(mContext, AddHouseZzActivity.class));
            }else {
                ToastUtils.showShort("添加房源数已达上限，请前往开通个人专属服务添加更多房源信息。");
                mContext.startActivity(new Intent(mContext, VipPersonActivity.class));
            }
            dismiss();

        });

        addHz.setOnClickListener(v -> {
            if (AppConfig.isPersonVip() || mHouseNum <= AppConfig.FREE_NUM){
                mContext.startActivity(new Intent(mContext, AddHouseHzActivity.class));
            }else {
                ToastUtils.showShort("添加房源数已达上限，请前往开通个人专属服务添加更多房源信息。");
                mContext.startActivity(new Intent(mContext, VipPersonActivity.class));
            }
            dismiss();
        });

        addKh.setOnClickListener(v -> {
            if (AppConfig.isPersonVip() || mCusNum <= AppConfig.FREE_NUM) {
                Intent intent = new Intent(mContext, AddCustomerActivity.class);
                intent.putExtra("flag", "add");
                mContext.startActivity(intent);
            }else {
                ToastUtils.showShort("添加客户数已达上限，请前往开通个人专属服务添加更多客户信息。");
                mContext.startActivity(new Intent(mContext, VipPersonActivity.class));
            }

            dismiss();
        });


    }

}
